package org.deadline.model.user;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.deadline.model.baseapp.BaseEntity;
import org.hibernate.annotations.Generated;
import org.hibernate.annotations.GenerationTime;

@Entity
public class PersonFilter extends BaseEntity  implements Serializable {

    private boolean passwordExpired;

    private boolean agreementLicence;

    private boolean welcomePage;

    private boolean profileUpdated;

    private boolean firstTimeUser;

    @ManyToOne
    private Person person;

	@Id
	@Column(name="id",unique=true,nullable=false)
	@SequenceGenerator(name="person_filter_seq_gen",sequenceName="person_filter_seq")
	@GeneratedValue(generator="person_filter_seq_gen",strategy=GenerationType.TABLE)
	@Generated(GenerationTime.INSERT)
	private Long id;

	
	public String toJson() {
        return new JSONSerializer().exclude("*.class").deepSerialize(this);
    }

	public static PersonFilter fromJsonToPersonFilter(String json) {
        return new JSONDeserializer<PersonFilter>().use(null, PersonFilter.class).deserialize(json);
    }

	public static String toJsonArray(Collection<PersonFilter> collection) {
        return new JSONSerializer().exclude("*.class").deepSerialize(collection);
    }

	public static Collection<PersonFilter> fromJsonArrayToPersonFilters(String json) {
        return new JSONDeserializer<List<PersonFilter>>().use(null, ArrayList.class).use("values", PersonFilter.class).deserialize(json);
    }

	private static final long serialVersionUID = 1L;

	public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

	public boolean isPasswordExpired() {
        return this.passwordExpired;
    }

	public void setPasswordExpired(boolean passwordExpired) {
        this.passwordExpired = passwordExpired;
    }

	public boolean isAgreementLicence() {
        return this.agreementLicence;
    }

	public void setAgreementLicence(boolean agreementLicence) {
        this.agreementLicence = agreementLicence;
    }

	public boolean isWelcomePage() {
        return this.welcomePage;
    }

	public void setWelcomePage(boolean welcomePage) {
        this.welcomePage = welcomePage;
    }

	public boolean isProfileUpdated() {
        return this.profileUpdated;
    }

	public void setProfileUpdated(boolean profileUpdated) {
        this.profileUpdated = profileUpdated;
    }

	public boolean isFirstTimeUser() {
        return this.firstTimeUser;
    }

	public void setFirstTimeUser(boolean firstTimeUser) {
        this.firstTimeUser = firstTimeUser;
    }

	public Person getPerson() {
        return this.person;
    }

	public void setPerson(Person person) {
        this.person = person;
    }

	public Long getId() {
	    return this.id;
	}

	public void setId(Long id) {
	    this.id = id;
	}

	}
